<%@ page import="com.situ.web.pojo.entity.Student" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2024/4/18
  Time: 9:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        // JSP内置对象： request、response、session、application、pageContext、page
        //1.普通字符串
        pageContext.setAttribute("name", "zhangsan");
        request.setAttribute("name", "lisi");
        //2.Student对象
        Student student = new Student(1, "zhansga", 23, "男", 1);
        session.setAttribute("student", student);
        //3.List<Student>
        List<Student> list = new ArrayList<>();
        Student student1 = new Student(1, "zhangsan1", 23, "男", 2);
        Student student2 = new Student(2, "zhangsan2", 23, "男", 2);
        Student student3 = new Student(3, "zhangsan3", 23, "男", 3);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        application.setAttribute("list", list);
    %>

    <%--JSP表达式--%>
    <%=pageContext.getAttribute("name")%><br>
    <%=request.getAttribute("name")%><br>
    <%
        Student stu = (Student) session.getAttribute("student");
    %>
    <%=stu.getName()%><br>
    <%=stu.getAge()%><br>
    <%
        List<Student> stuList = (List<Student>) application.getAttribute("list");
    %>
    <%=stuList.get(0).getName()%>

    <hr>
    <%--EL表达式--%>
    ${pageScope.name}<br>
    ${requestScope.name}<br>
    ${name}<br>
    ${sessionScope.student.name}<br>
    ${student.name}<br>
    ${list}<br>
    ${list[0].name}
</body>
</html>
